#pragma once

#include <string>
#include <iostream>
#include <GL\glui.h>
#include "Light.h"

using namespace std;

class Spot: public Light
{
private:
	GLfloat location[4];
	GLfloat ambient[4];
	GLfloat difuse[4];
	GLfloat specular[4];
	GLfloat target[3];
	int enabled;
	float angle;
	float exponent;
public:
	Spot() {}
	void setLocation(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
	{
		location[0] = x;
		location[1] = y;
		location[2] = z;
		location[3] = w;
	}

	void setAmbient(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
	{
		ambient[0] = r;
		ambient[1] = g;
		ambient[2] = b;
		ambient[3] = a;
	}

	void setDiffuse(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
	{
		difuse[0] = r;
		difuse[1] = g;
		difuse[2] = b;
		difuse[3] = a;
	}

	void setSpecular(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
	{
		specular[0] = r;
		specular[1] = g;
		specular[2] = b;
		specular[3] = a;
	}

	void setTarget(GLfloat x, GLfloat y, GLfloat z)
	{
		target[0] = x;
		target[1] = y;
		target[2] = z;
	}

	void setEnabled(int e)
	{
		enabled = e;
	}

	void setExponent(float ex)
	{
		exponent = ex;
	}

	void setAngle(float ang)
	{
		angle = ang;
	}

	void applyLight()
	{
		glEnable(getLightID());
		glLightfv(getLightID(), GL_AMBIENT, ambient);
		glLightfv(getLightID(), GL_DIFFUSE, difuse);
		glLightfv(getLightID(), GL_SPECULAR, specular);
		glLightf(getLightID(), GL_SPOT_CUTOFF, angle);
        glLightfv(getLightID(), GL_SPOT_DIRECTION, target);
		glLightfv(getLightID(), GL_POSITION, location);
	}

	void turnOff() 
	{
		glDisable(getLightID());
	}

	void turnOn() 
	{
		glEnable(getLightID());
	}
}; 